﻿@model IEnumerable<MVCDemo.Models.EmployeeEx>
@using MVCDemo.Models;

@{
    ViewBag.Title = "List of employees";
}

<script type="text/javascript" language="javascript">
    $(function () {
        $("#checkAll").click(function () {
            $("input[name='employeeIdsToDelete']").attr("checked", this.checked);
        });

        $("input[name='employeeIdsToDelete']").click(function () {
            if ($("input[name='employeeIdsToDelete']").length == $("input[name='employeeIdsToDelete']:checked").length) {
                $("#checkAll").attr("checked", "checked");
            }
            else {
                $("#checkAll").removeAttr("checked");
            }
        });

        $("#btnSubmit").click(function () {
            var count = $("input[name='employeeIdsToDelete']:checked").length;
            if (count == 0) {
                alert("No rows selected to delete");
                return false;
            }
            else {
                return confirm(count + "row(s) will be deleted");
            }
        });
    });
</script>


@using (Html.BeginForm("Delete", "EmployeeEx", FormMethod.Post))
{
    
    <text>Employee list retrieved @@ </text> @DateTime.Now.ToString();
    foreach (EmployeeEx item in @Model)
    {
    @Html.Partial("_EmployeeEx", item)
    }
    <br />
    <text>Select : </text>
    <input type="checkbox" name="select" id="checkAll" /> <text>All</text>
    <br />
    <br />
    <input type="submit" value="Delete selected employees" id="btnSubmit" />
}
<br /><br />
@Html.Action("GetEmployeeCount")